package com.xuecheng.learning.controller;

import com.xuecheng.commons.model.dto.LearningProgressDto;
import com.xuecheng.commons.model.dto.RecordDto;
import com.xuecheng.commons.model.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.learning.service.CourseRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 选课记录前端控制器
 * </p>
 *
 * @author HuangYuwu
 */
@Slf4j
@RestController
public class CourseRecordController {

    @Autowired
    private CourseRecordService  courseRecordService;

    /**
     * 我的选课记录
     * @param coursePubId
     * @return
     */
    @GetMapping("/courseRecord/myCourseRec/{coursePubId}")
    public ResponseResult myCourseRecord(@PathVariable("coursePubId")Long coursePubId){
        return courseRecordService.myCourseRecord(coursePubId);
    }

    /**
     * 课程详情页查询媒资播放地址
     * @param coursePubId
     * @param mediaId
     * @param teachplanId
     * @return
     */
    @GetMapping("/courseRecord/resource-url")
    public ResponseResult resourceUrl(Long coursePubId,Long mediaId,Long teachplanId){
        return courseRecordService.resourceUrl(coursePubId,mediaId,teachplanId);
    }

    /**
     * 免费课程新增选课，或者更新学习进度
     * @param learningProgressDto
     * @return
     */
    @PostMapping("/courseRecord/progress")
    public ResponseResult progress(@RequestBody LearningProgressDto learningProgressDto){
        return courseRecordService.progress(learningProgressDto);
    }

}
